package com.proactive.webapp.controller;

import java.util.ArrayList;
import java.util.List;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.proactive.webapp.dao.CourseCategory2DAO;
import com.proactive.webapp.entity.CourseCategory2;

@Controller
public class CourseCategoryController {
	ApplicationContext context =  new ClassPathXmlApplicationContext("spring-module.xml");
	
	@RequestMapping(value = "/getCourseCategory2", method = RequestMethod.GET)
	public @ResponseBody List<CourseCategory2> getCourseCategory2List(int category1ID) throws Exception {
		CourseCategory2DAO courseCategory2DAO = (CourseCategory2DAO) context.getBean("courseCategory2DAO");
		List<CourseCategory2> category2List = new ArrayList<CourseCategory2>();
		category2List = courseCategory2DAO.getList(category1ID);
		
		return category2List;		
	}
}
